import java.util.*;

public class Test {
    public static MyBinaryTree.Node structure(String str, MyBinaryTree.Node head){
        if (str.charAt(0) != '#'){
            head.value = str.charAt(0);
        }else {
            return head;
        }
        head.left = new MyBinaryTree.Node();
        structure(str.substring(1),head.left);
        head.right = new MyBinaryTree.Node();
        structure(str.substring(1),head.right);
        return head;
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        MyBinaryTree.Node root = new MyBinaryTree.Node();
        if (str == null || str.charAt(0) == '#') {
            return;
        }
        structure(str, root);

    }
    public static void main7(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        MyBinaryTree.Node head = tree.create();
        MyBinaryTree.Node head4 = tree.create4();
        MyBinaryTree.Node head5 = tree.create5();
        System.out.println(tree.isInclude(head, head));
        System.out.println(tree.isInclude(head, head4));
        System.out.println(tree.isInclude(head, head5));
    }
    public static void main6(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        MyBinaryTree.Node head = tree.create();
        System.out.println(tree.isfull(head));
        MyBinaryTree.Node head2 = tree.create2();
        System.out.println(tree.isfull(head2));
        System.out.println(tree.isSame(head, head));
        System.out.println(tree.isSame(head, head2));
        MyBinaryTree.Node head3 = tree.create3();
        System.out.println(tree.isSame(head, head3));
    }
    public static void main5(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        MyBinaryTree.Node node = tree.create();
        Queue<MyBinaryTree.Node> queue = new LinkedList<>();
        tree.puDisply(node,queue);
        System.out.println();
        tree.puDisply2(node);
        System.out.println("===========");
        List<List<Character>> ret = tree.puDisply3(node);
        System.out.println(ret);
    }
    public static void main4(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        MyBinaryTree.Node node= tree.create();
        System.out.println(tree.size2(node));
        System.out.println(tree.charFind(node, 'a'));
        System.out.println(tree.charFind(node, 'A'));
        System.out.println(tree.charFind2(node, 'a'));
        System.out.println(tree.charFind2(node, 'A'));
        System.out.println(tree.charFind2(node, 'B').value);
    }
    public static void main3(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        MyBinaryTree.Node node= tree.create();
        System.out.println(tree.leafSize1(node));
        System.out.println(tree.leafSize2(node));
        System.out.println(tree.leafK(node, 1));
        System.out.println(tree.leafK(node, 2));
        System.out.println(tree.leafK(node, 3));
        System.out.println(tree.leafK(node, 5));
        System.out.println(tree.treeHeight(node));

    }
    public static void main2(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        MyBinaryTree.Node node= tree.create();
        int tmp1 = tree.size1(node);
        System.out.println(tmp1);
        tmp1 = tree.size1(node);
        System.out.println(tmp1);
        int tmp2 = tree.size2(node);
        System.out.println(tmp2);
        tmp2 = tree.size2(node);
        System.out.println(tmp2);
        System.out.println(tree.leafSize1(node));
    }
    public static void main1(String[] args) {
        MyBinaryTree tree = new MyBinaryTree();
        MyBinaryTree.Node node = tree.create();
        tree.AdisPlay(node);
        System.out.println();
        tree.BdisPlay(node);
        System.out.println();
        tree.CdisPlay(node);
        /*List<Integer> list = new LinkedList<>();
        list.addAll(list);*/
    }
}
